/* eslint-disable no-undef */
<template>
  <div class="productSort product-con">
    <form @submit.prevent="submitForm">
      <div class="header acea-row row-center-wrapper" ref="header">
        <div class="head">
          <el-row :gutter="20">
            <el-col :span="16">
              <el-row :gutter="20" class="name1 des">{{
                shopInfo.name
              }}</el-row>
              <el-row :gutter="20" class="shopdes des2">{{
                shopInfo.address
              }}</el-row>
            </el-col>
            <el-col :span="6">
              <el-image
                style="width: 1.2rem; height:1.2rem; margin-top: 10px; border-radius: 10px;"
                :src="shopInfo.image"
                :fit="fit"
              ></el-image>
            </el-col>
          </el-row>
        </div>
      </div>
    </form>
    <div class="aside">
      <div
        class="item acea-row row-center-wrapper"
        :class="{ active: isActive == index }"
        v-for="(item, index) in category"
        :key="index"
        @click="asideTap(index)"
      >
        <span>{{ item.cateName }}</span>
      </div>
    </div>
    <div class="conter" @scroll.native="onScroll">
      <div
        class="listw always"
        v-for="(item, index) in category"
        :key="index"
        :class="{ change: isActive == index }"
      >
        <div class="title acea-row row-center-wrapper" ref="title">
          <div class="line"></div>
          <div class="name">{{ item.cateName }}</div>
          <div class="line"></div>
        </div>
        <div class="list acea-row">
          <router-link
            class="item acea-row row-column row-middle"
            v-for="(child, index) in item.children"
            :key="index"
            :to="{
              path: '/detail/' + child.id + '?storeId=' + shopInfo.id
            }"
          >
            <div class="content">
              <div class="picture">
                <img :src="child.image" />
              </div>
              <div class="message">
                <div class="shop_name">{{ child.storeName }}</div>
                <div class="shop_num">月售{{ child.sales }}份</div>
                <div class="shop_price">￥ {{ child.price }}</div>
              </div>
              <i
                class="carts iconfont icon-jia"
                @click.prevent="joinCart(child)"
              ></i>
            </div>
          </router-link>
        </div>
      </div>
      <div style="width: 100%; height: 1.5rem;"></div>
    </div>

    <!-- <div class="footers">
      <div class="footer1">
        <el-image
          style="width: 0.8rem; height:0.8rem; margin: 10px 0 0 8px; border-radius: 10px;"
          src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
          :fit="fit"
        ></el-image>
        <div class="jishu">2</div>
      </div>
      <div class="footer2">共计￥800</div>
      <div class="footer3">选好了</div>
    </div>-->
    <Product-window
      v-on:changeFun="changeFun"
      :attr="attr"
      :storeId="shopInfo.id"
    >
      <div class="footer acea-row row-between-wrapper">
        <div class="item" @click="setCollect">
          <div
            class="iconfont"
            :class="storeInfo.userCollect ? 'icon-shoucang1' : 'icon-shoucang'"
          ></div>
          <div>收藏</div>
        </div>
        <router-link
          :to="'/cart'"
          class="item animated"
          :class="animated === true ? 'bounceIn' : ''"
        >
          <div class="iconfont icon-gouwuche1">
            <span class="num bg-color-red" v-if="CartCount > 0">
              {{ CartCount }}
            </span>
          </div>
          <div>购物车</div>
        </router-link>
        <div class="bnt acea-row">
          <div class="joinCart" @click="goCat(0)">加入购物车</div>
          <div class="buy" @click="tapBuy">立即购买</div>
        </div>
      </div>
    </Product-window>

    <div style="height:1.2rem;"></div>
  </div>
</template>
<script>
import debounce from "lodash.debounce";
import {
  getCategory,
  getProductDetail,
  postCartAdd,
  getCartCount,
  getProductPoster,
  getSystemStore,
  getCartList
} from "@api/store";
import { mapGetters } from "vuex";
import { getCollectAdd, getCollectDel } from "@api/user";
import { trim } from "../../utils";
import ProductWindow from "@components/ProductWindow";
import cookie from "@utils/store/cookie";
import { isWeixin } from "@utils/index";
// import "@assets/css/swiper.min.css";

const LONGITUDE = "user_longitude";
const LATITUDE = "user_latitude";
const MAPKEY = "mapKey";

export default {
  // name: "GoodsClass",
  components: {
    ProductWindow
  },
  props: {},
  data: function() {
    return {
      category: [],
      navActive: 0,
      search: "",
      lock: false,
      drawer: false,
      direction: "ttb",
      num: 1,
      index: 1,
      isActive: 0, //索引值默认为0，即item1为默认激活的选项卡,
      locationShow: false,
      shareInfoStatus: false,
      weixinStatus: false,
      mapShow: false,
      mapKey: "",
      posterData: {
        codeBase: "",
        title: "",
        price: "",
        code: ""
      },
      posterImageStatus: false,
      animated: false,
      coupon: {
        coupon: false,
        list: []
      },
      attr: {
        cartAttr: false,
        productAttr: [],
        productSelect: {}
      },
      isOpen: false, //是否打开属性组件
      productValue: [],
      id: 0,
      storeInfo: {},
      couponList: [],
      attrTxt: "请选择",
      attrValue: "",
      cart_num: 1, //购买数量
      replyCount: "",
      replyChance: "",
      reply: [],
      priceName: 0,
      CartCount: 0,
      posters: false,
      banner: [{}, {}],
      swiperRecommend: {
        pagination: {
          el: ".swiper-pagination",
          clickable: true
        },
        autoplay: false,
        loop: false,
        speed: 1000,
        observer: true,
        observeParents: true
      },
      system_store: {},
      qqmapsdk: null,
      shopInfo: {} //商家信息
    };
  },
  computed: mapGetters(["isLogin"]),
  watch: {
    "$route.params.pid": function(n) {
      console.log(n);
      if (n) {
        this.activeCateId(n);
      }
    }
  },
  mounted: function() {
    document.addEventListener("scroll", this.onScroll, false);
    this.loadCategoryData();
    this.getShopInfo();
  },
  methods: {
    // 获取商家信息
    getShopInfo() {
      let that = this;
      that.$set(that, "storeId", this.$route.params.id);
      getSystemStore(this.$route.query.id).then(res => {
        console.log(res);
        this.shopInfo = res.data;
      });
    },
    //底部开始

    getStoreList() {
      //return this.$dialog.error("多门店开发中,四月发布哦!");
      this.$store.commit("GET_TO", "details");
      this.$router.push("/shop/storeList/details");
    },
    getWXLocation() {
      if (isWeixin()) {
        let _this = this;
        // eslint-disable-next-line no-undef
        wechatEvevt("getLocation", { type: "wgs84" })
          .then(res => {
            let latitude = res.latitude; // 纬度
            let longitude = res.longitude; // 经度
            cookie.set(LATITUDE, latitude);
            cookie.set(LONGITUDE, longitude);
          })
          .catch(res => {
            if (res.is_ready) {
              res.wx.getLocation({
                success(res) {
                  let latitude = res.latitude; // 纬度
                  let longitude = res.longitude; // 经度
                  cookie.set(LATITUDE, latitude);
                  cookie.set(LONGITUDE, longitude);
                },
                cancel() {
                  _this.$dialog.error("取消获取位置");
                  cookie.remove(LATITUDE);
                  cookie.remove(LONGITUDE);
                },
                fail() {
                  _this.$dialog.error("授权失败");
                  cookie.remove(LATITUDE);
                  cookie.remove(LONGITUDE);
                }
              });
            }
          });
      } else {
        if (!this.mapKey)
          return this.$dialog.error("定位失败，请配置您的腾讯地图key");
        let loc;
        // 腾讯地图监听定位组件的message事件
        console.log("aaaa:" + this.mapKey);
        if (this.mapKey) this.locationShow = true;
        window.addEventListener(
          "message",
          function(event) {
            loc = event.data; // 接收位置信息 LONGITUDE
            console.log("location", loc);
            if (loc && loc.module == "geolocation") {
              cookie.set(LATITUDE, loc.lat);
              cookie.set(LONGITUDE, loc.lng);
            } else {
              cookie.remove(LATITUDE);
              cookie.remove(LONGITUDE);
              console.log("定位失败");
            }
          },
          false
        );
      }
    },
    showMap: function() {
      if (isWeixin()) {
        let config = {
          latitude: parseFloat(this.system_store.latitude),
          longitude: parseFloat(this.system_store.longitude),
          name: this.system_store.name,
          address: this.system_store.address
        };
        // eslint-disable-next-line no-undef
        wechatEvevt("openLocation", config)
          .then(res => {
            console.log(res);
          })
          .catch(res => {
            if (res.is_ready) {
              res.wx.openLocation(config);
            }
          });
      } else {
        if (!this.mapKey)
          return this.$dialog.error(
            "暂无法使用查看地图，请配置您的腾讯地图key"
          );
        this.mapShow = true;
      }
    },
    updateTitle() {
      document.title = this.storeInfo.storeName || this.$route.meta.title;
    },
    setOpenShare: function() {
      var data = this.storeInfo;
      var href = location.href;
      if (isWeixin()) {
        if (this.isLogin) {
          // eslint-disable-next-line no-undef
          getUserInfo().then(res => {
            href =
              href.indexOf("?") === -1
                ? href + "?spread=" + res.data.uid
                : href + "&spread=" + res.data.uid;
            var configAppMessage = {
              desc: data.storeInfo,
              title: data.storeName,
              link: href,
              imgUrl: data.image
            };
            // eslint-disable-next-line no-undef
            wechatEvevt(
              ["updateAppMessageShareData", "updateTimelineShareData"],
              configAppMessage
            )
              .then(res => {
                console.log(res);
              })
              .catch(res => {
                console.log(res);
                if (res.is_ready) {
                  res.wx.updateAppMessageShareData(configAppMessage);
                  res.wx.updateTimelineShareData(configAppMessage);
                }
              });
          });
        } else {
          var configAppMessage = {
            desc: data.storeInfo,
            title: data.storeName,
            link: href,
            imgUrl: data.image
          };
          // eslint-disable-next-line no-undef
          wechatEvevt(
            ["updateAppMessageShareData", "updateTimelineShareData"],
            configAppMessage
          )
            .then(res => {
              console.log(res);
            })
            .catch(res => {
              console.log(res);
              if (res.is_ready) {
                res.wx.updateAppMessageShareData(configAppMessage);
                res.wx.updateTimelineShareData(configAppMessage);
              }
            });
        }
      }
    },
    setShareInfoStatus: function() {
      this.shareInfoStatus = !this.shareInfoStatus;
      this.posters = false;
    },
    setPosterImageStatus: function() {
      let that = this;
      getProductPoster(that.id)
        .then(res => {
          that.posterData.codeBase = res.data;
        })
        .catch(res => {
          that.$dialog.error(res.msg);
          that.$router.go(-1);
        });
      var sTop = document.body || document.documentElement;
      sTop.scrollTop = 0;
      this.posterImageStatus = !this.posterImageStatus;
      this.posters = false;
    },
    //产品详情接口；
    productCon: function() {
      let that = this;
      let data = {
        latitude: cookie.get(LATITUDE) || "",
        longitude: cookie.get(LONGITUDE) || ""
      };
      getProductDetail(that.id, data)
        .then(res => {
          that.$set(that, "storeInfo", res.data.storeInfo);
          that.$set(that.attr, "productAttr", res.data.productAttr);
          that.$set(that, "productValue", res.data.productValue);
          that.$set(that, "replyCount", res.data.replyCount);
          that.$set(that, "replyChance", res.data.replyChance);
          that.reply = res.data.reply ? [res.data.reply] : [];
          that.$set(that, "reply", that.reply);
          that.$set(that, "priceName", res.data.priceName);
          //that.posterData.codeBase = that.storeInfo.codeBase;
          // if (that.storeInfo.storeName.length > 30) {
          //   that.posterData.title =
          //     that.storeInfo.storeName.substring(0, 30) + "...";
          // } else {
          //   that.posterData.title = that.storeInfo.storeName;
          // }
          //that.posterData.price = that.storeInfo.price;

          //that.posterData.code = that.storeInfo.codeBase;
          that.system_store = res.data.systemStore;
          //console.log(222);
          //console.log(res.data);
          that.mapKey = res.data.mapKey;
          cookie.set(MAPKEY, res.data.mapKey);
          that.updateTitle();
          that.DefaultSelect();
          that.getCartCount();
          that.setOpenShare();

          if (!cookie.get(LATITUDE) && !cookie.get(LONGITUDE))
            this.getWXLocation();
        })
        .catch(res => {
          that.$dialog.error(res.msg);
          that.$router.go(-1);
        });
    },
    //默认选中属性；
    DefaultSelect: function() {
      let productAttr = this.attr.productAttr;
      let value = [];
      for (let i = 0; i < productAttr.length; i++) {
        this.$set(productAttr[i], "index", 0);
        //console.log(productAttr[i])
        //console.log(productAttr[i].attrValueArr[0])
        value.push(productAttr[i].attrValueArr[0]);
      }
      // console.log(9999999)
      //console.log(value)
      // console.log(value.sort().join(","))
      //sort();排序函数:数字-英文-汉字；
      let productSelect = this.productValue[value.sort().join(",")];
      console.log(productSelect);
      if (productSelect && productAttr.length) {
        this.$set(
          this.attr.productSelect,
          "store_name",
          this.storeInfo.storeName
        );
        console.log("productSelect:" + productSelect);
        this.$set(this.attr.productSelect, "image", productSelect.image);
        this.$set(this.attr.productSelect, "price", productSelect.price);
        this.$set(this.attr.productSelect, "stock", productSelect.stock);
        this.$set(this.attr.productSelect, "unique", productSelect.unique);
        this.$set(this.attr.productSelect, "cart_num", 1);
        this.$set(this, "attrValue", value.sort().join(","));
        this.$set(this, "attrTxt", "已选择");
      } else if (!productSelect && productAttr.length) {
        this.$set(
          this.attr.productSelect,
          "store_name",
          this.storeInfo.storeName
        );
        this.$set(this.attr.productSelect, "image", this.storeInfo.image);
        this.$set(this.attr.productSelect, "price", this.storeInfo.price);
        this.$set(this.attr.productSelect, "stock", 0);
        this.$set(this.attr.productSelect, "unique", "");
        this.$set(this.attr.productSelect, "cart_num", 0);
        this.$set(this, "attrValue", "");
        this.$set(this, "attrTxt", "请选择");
      } else if (!productSelect && !productAttr.length) {
        this.$set(
          this.attr.productSelect,
          "store_name",
          this.storeInfo.storeName
        );
        this.$set(this.attr.productSelect, "image", this.storeInfo.image);
        this.$set(this.attr.productSelect, "price", this.storeInfo.price);
        this.$set(this.attr.productSelect, "stock", this.storeInfo.stock);
        this.$set(
          this.attr.productSelect,
          "unique",
          this.storeInfo.unique || ""
        );
        this.$set(this.attr.productSelect, "cart_num", 1);
        this.$set(this, "attrValue", "");
        this.$set(this, "attrTxt", "请选择");
      }
    },
    //购物车；
    ChangeCartNum: function(changeValue) {
      //changeValue:是否 加|减
      //获取当前变动属性
      let productSelect = this.productValue[this.attrValue];
      //如果没有属性,赋值给商品默认库存
      if (productSelect === undefined && !this.attr.productAttr.length)
        productSelect = this.attr.productSelect;
      //无属性值即库存为0；不存在加减；
      if (productSelect === undefined) return;
      let stock = productSelect.stock || 0;
      let num = this.attr.productSelect;
      if (changeValue) {
        num.cart_num++;
        if (num.cart_num > stock) {
          this.$set(this.attr.productSelect, "cart_num", stock);
          this.$set(this, "cart_num", stock);
        }
      } else {
        num.cart_num--;
        if (num.cart_num < 1) {
          this.$set(this.attr.productSelect, "cart_num", 1);
          this.$set(this, "cart_num", 1);
        }
      }
    },
    //将父级向子集多次传送的函数合二为一；
    changeFun: function(opt) {
      if (typeof opt !== "object") opt = {};
      let action = opt.action || "";
      let value = opt.value === undefined ? "" : opt.value;
      this[action] && this[action](value);
    },
    //打开优惠券插件；
    couponTap: function() {
      let that = this;
      that.coupons();
      that.coupon.coupon = true;
    },
    changecoupon: function(msg) {
      this.coupon.coupon = msg;
      this.coupons();
    },
    currentcoupon: function(res) {
      let that = this;
      that.coupon.coupon = false;
      that.$set(that.coupon.list[res], "is_use", true);
    },
    //可领取优惠券接口；
    coupons: function() {
      let that = this,
        q = { page: 1, limit: 20 };
      // eslint-disable-next-line no-undef
      getCoupon(q).then(res => {
        that.$set(that, "couponList", res.data || []);
        that.$set(that.coupon, "list", res.data);
      });
    },
    //打开属性插件；
    selecAttrTap: function() {
      this.attr.cartAttr = true;
      this.isOpen = true;
    },
    changeattr: function(msg) {
      console.log("changeattr", msg);
      this.attr.cartAttr = msg;
      this.isOpen = false;
      this.$forceUpdate();
    },
    //选择属性；
    ChangeAttr: function(res) {
      console.log(res);
      let productSelect = this.productValue[res];
      console.log(this.productValue);
      console.log(productSelect);
      if (productSelect) {
        this.$set(this.attr.productSelect, "image", productSelect.image);
        this.$set(this.attr.productSelect, "price", productSelect.price);
        this.$set(this.attr.productSelect, "stock", productSelect.stock);
        this.$set(this.attr.productSelect, "unique", productSelect.unique);
        this.$set(this.attr.productSelect, "cart_num", 1);
        this.$set(this, "attrValue", res);
        this.$set(this, "attrTxt", "已选择");
      } else {
        this.$set(this.attr.productSelect, "image", this.storeInfo.image);
        this.$set(this.attr.productSelect, "price", this.storeInfo.price);
        this.$set(this.attr.productSelect, "stock", 0);
        this.$set(this.attr.productSelect, "unique", "");
        this.$set(this.attr.productSelect, "cart_num", 0);
        this.$set(this, "attrValue", "");
        this.$set(this, "attrTxt", "请选择");
      }
    },
    //收藏商品
    setCollect: function() {
      let that = this,
        id = that.storeInfo.id,
        category = "product";
      if (that.storeInfo.userCollect) {
        getCollectDel(id, category).then(function() {
          that.storeInfo.userCollect = !that.storeInfo.userCollect;
        });
      } else {
        getCollectAdd(id, category).then(function() {
          that.storeInfo.userCollect = !that.storeInfo.userCollect;
        });
      }
    },
    //  点击加入购物车按钮
    joinCart: function(item) {
      let that = this;
      let data = {
        latitude: cookie.get(LATITUDE) || "",
        longitude: cookie.get(LONGITUDE) || ""
      };
      getProductDetail(item.id, data)
        .then(res => {
          that.$set(that, "storeInfo", res.data.storeInfo);
          that.$set(that.attr, "productAttr", res.data.productAttr);
          that.$set(that, "productValue", res.data.productValue);
          that.$set(that, "replyCount", res.data.replyCount);
          that.$set(that, "replyChance", res.data.replyChance);
          that.reply = res.data.reply ? [res.data.reply] : [];
          that.$set(that, "reply", that.reply);
          that.$set(that, "priceName", res.data.priceName);
          //that.posterData.codeBase = that.storeInfo.codeBase;
          // if (that.storeInfo.storeName.length > 30) {
          //   that.posterData.title =
          //     that.storeInfo.storeName.substring(0, 30) + "...";
          // } else {
          //   that.posterData.title = that.storeInfo.storeName;
          // }
          //that.posterData.price = that.storeInfo.price;

          //that.posterData.code = that.storeInfo.codeBase;
          that.system_store = res.data.systemStore;
          //console.log(222);
          //console.log(res.data);
          that.mapKey = res.data.mapKey;
          cookie.set(MAPKEY, res.data.mapKey);
          that.updateTitle();
          that.DefaultSelect();
          that.getCartCount();
          that.setOpenShare();

          if (!cookie.get(LATITUDE) && !cookie.get(LONGITUDE))
            this.getWXLocation();
        })
        .catch(res => {
          that.$dialog.error(res.msg);
          that.$router.go(-1);
        });
      //0=加入购物车
      this.goCat(0);
    },
    // 加入购物车；
    goCat: function(news) {
      let that = this,
        productSelect = that.productValue[this.attrValue];
      console.log(this.attrValue);
      //打开属性
      if (that.attrValue) {
        //默认选中了属性，但是没有打开过属性弹窗还是自动打开让用户查看默认选中的属性
        that.attr.cartAttr = !that.isOpen ? true : false;
      } else {
        if (that.isOpen) that.attr.cartAttr = true;
        else that.attr.cartAttr = !that.attr.cartAttr;
      }
      //只有关闭属性弹窗时进行加入购物车
      if (that.attr.cartAttr === true && that.isOpen === false)
        return (that.isOpen = true);
      //如果有属性,没有选择,提示用户选择
      console.log("=====");
      console.log(productSelect);
      if (
        that.attr.productAttr.length &&
        productSelect === undefined &&
        that.isOpen === true
      )
        return that.$dialog.toast({ mes: "产品库存不足，请选择其它" });
      let q = {
        // productId: that.id,
        productId: that.storeInfo.id,
        cartNum: that.attr.productSelect.cart_num,
        new: news,
        uniqueId:
          that.attr.productSelect !== undefined
            ? that.attr.productSelect.unique
            : ""
      };
      postCartAdd(q)
        .then(function(res) {
          that.isOpen = false;
          that.attr.cartAttr = false;
          if (news) {
            //  立即购买

            getCartList().then(ress => {
              let carts = [];
              carts = ress.data.valid;
              //把桌号id带过去
              if (carts.length) {
                // 如果购物车有商品，查询出来跳转到下单页面
                let ids = [];
                carts.map(product => {
                  ids.push(product.id);
                });
                that.$router.push({
                  path: "/order/submit/" + ids,
                  query: {
                    tableId: that.$route.query.tableId,
                    storeId: that.shopInfo.id
                  }
                });
              } else {
                // 如果没有，直接结算当前商品
                that.$router.push({
                  path: "/order/submit/" + res.data.cartId,
                  query: { storeId: that.shopInfo.id }
                });
              }
            });
          } else {
            // 加入购物车
            that.$dialog.toast({
              mes: "添加购物车成功",
              callback: () => {
                that.getCartCount(true);
              }
            });
          }
        })
        .catch(res => {
          that.isOpen = false;
          return that.$dialog.toast({ mes: res.msg });
        });
    },
    //获取购物车数量
    getCartCount: function(isAnima) {
      let that = this;
      const isLogin = that.isLogin;
      if (isLogin) {
        getCartCount({ numType: 0 }).then(res => {
          that.CartCount = res.data.count;
          //加入购物车后重置属性
          if (isAnima) {
            that.animated = true;
            setTimeout(function() {
              that.animated = false;
            }, 500);
          }
        });
      }
    },
    //立即购买；
    tapBuy: function() {
      //  1=直接购买
      this.goCat(1);
    },
    listenerActionSheet: function() {
      if (isWeixin() === true) {
        this.weixinStatus = true;
      }
      this.posters = true;
    },
    listenerActionClose: function() {
      this.posters = false;
    },

    //底部结束

    activeCateId(n) {
      let index = 0;
      n = parseInt(n);
      if (!n) return;
      this.category.forEach((cate, i) => {
        if (cate.id === n) index = i;
      });

      if (index !== this.navActive) {
        this.asideTap(index);
      }
    },
    loadCategoryData() {
      let data = {
        storeId: this.$route.query.id
      };
      getCategory(data).then(res => {
        this.category = res.data;
        this.$nextTick(() => {
          if (this.$route.params.pid) this.activeCateId(this.$route.params.pid);
          else this.onScroll();
        });
      });
    },
    submitForm: function() {
      var val = trim(this.search);
      if (val) {
        this.$router.push({
          path: "/goods_list",
          query: { s: val }
        });
        setTimeout(() => (this.search = ""), 500);
      }
    },
    asideTap(index) {
      const top =
        this.$refs.title[index].offsetTop -
        this.$refs.header.offsetHeight -
        window.scrollY;

      this.lock = true;

      window.scrollBy({ top, left: 0, behavior: "smooth" });
      this.isActive = index;
    },
    onScroll: debounce(function() {
      if (this.lock) {
        this.lock = false;
        return;
      }
      const headerHeight = this.$refs.header.offsetHeight,
        { scrollY } = window,
        titles = this.$refs.title;
      titles.reduce((initial, title, index) => {
        if (initial) return initial;
        const parent = title.parentNode || title.parentElement;
        if (
          scrollY + headerHeight + 15 <
          title.offsetTop + parent.offsetHeight
        ) {
          initial = true;
          this.navActive = index;
        }
        return initial;
      }, false);
    }, 500)
  },

  beforeDestroy: function() {
    document.removeEventListener("scroll", this.onScroll, false);
  }
};
</script>

<style scoped>
.always {
  display: none;
}
.change {
  display: block;
}
.item.active {
  color: #1abb1d;
  border-left: 2px solid #1abb1d;
}
.product-window .cart {
  /* height: .5rem;right: .2rem;
  margin: .2rem 0 0 .1rem; */
  height: 0.5rem;
  right: 0.2rem;
  margin: 0.2rem 0 0 0.1rem;
}
/* .carts {
    position: absolute;
    width: .5rem;
    height: .5rem;
    right: .2rem;
    margin: .2rem 0 0 .1rem;
} */
.head {
  width: 94%;
  height: 1.8rem;
  border-radius: 0.2rem;
  background: white;
  border: 1px solid silver;
  margin: 0.2rem 0 0.1rem 0;
}

.des {
  width: 100%;
  height: 0.6rem;
  padding-left: 20px;
  line-height: 0.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.des2 {
  width: 100%;
  height: 0.4rem;
  padding-left: 20px;
  line-height: 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  display: flex;
}
.message {
  display: flex;
  flex-direction: column;
  margin-left: 20px;
  width: 3.5rem;
}
.message div {
  width: 3.5rem;
  height: 0.4rem;
}
.shop_name {
  font-size: 1.2em;
  color: black;
}
.shop_num {
  font-size: 0.8em;
  color: #e6e6e6;
}
.shop_price {
  color: red;
}
.carts {
  position: absolute;
  width: 0.5rem;
  height: 0.5rem;
  right: 0.2rem;
  margin: 0.2rem 0 0 0.1rem;
  font-size: 0.5rem;
  color: #409eff;
}

.jishu {
  width: 0.4rem;
  height: 0.4rem;
  color: white;
  background: red;
  font-size: 0.5em;
  text-align: center;
  line-height: 0.4rem;
  border-radius: 5px;
  margin-left: -6px;
  z-index: 9999;
}

.conter {
  width: 75%;
  height: 100%;
}

.name1 {
  font-size: 1.5em;
  font-weight: bold;
  margin-top: 10px;
}

.footers {
  display: flex;
  width: 100%;
  height: 0rem;
  position: fixed;
  bottom: 1.5rem;
  z-index: 8888;
}
.footer1 {
  width: 20%;
  height: 1rem;
  background: #1a4273;
  display: flex;
}

.footer2 {
  width: 40%;
  height: 1rem;
  background: #1a4273;
  line-height: 1rem;
  color: white;
}

.footer3 {
  width: 40%;
  height: 1rem;
  background: #eb702d;
  text-align: center;
  line-height: 1rem;
  color: white;
}
.guige {
  position: absolute;
  width: 1.2rem;
  height: 1.2rem;
  margin: -1.4rem 0 0 0.3rem;
}

.mess1 {
  width: 4.5rem;
  position: absolute;
  margin: -1.4rem 0 0 2rem;
}

.mess1 p {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0.1rem 0 0 0;
}

.gui_name {
  font-size: 0.4rem;
}
.gui_num {
  font-size: 0.3rem;
}

.gui_num1 {
  color: #1abb1d;
}
.gui_num2 {
  font-size: 0.4rem;
  color: #1abb1d;
}
.gui_num3 {
  font-size: 0.2rem;
  color: #bbbbbb;
  margin-left: 0.3rem;
}
.gui1 {
  width: 98%;
  display: flex;
  flex-wrap: wrap;
}
.gui1 span {
  border: #8c8c8c 1px solid;
  padding: 0.1rem 0.1rem 0.1rem 0.1rem;
  margin: 0.2rem 0 0 0.2rem;
}
.gui_footer {
  width: 100%;
  position: fixed;
  bottom: 0.2rem;
  display: flex;
  justify-content: space-around;
}
.gui_p {
  margin: 0.2rem 0 0 0.2rem;
}
.gui_con {
  overflow: auto;
  width: 100%;
  height: 4.3rem;
  overflow-y: scroll;
}
.select {
  background: #1abb1d;
}
.noselect {
  background: #ffffff;
}

.activity_pin {
  width: auto;
  height: 0.44rem;
  background: linear-gradient(
    90deg,
    rgba(233, 51, 35, 1) 0%,
    rgba(250, 101, 20, 1) 100%
  );
  opacity: 1;
  border-radius: 0.22rem;
  padding: 0 0.2rem;
  margin-left: 0.19rem;
}
.activity_miao {
  width: auto;
  height: 0.44rem;
  padding: 0 0.2rem;
  background: linear-gradient(
    90deg,
    rgba(250, 102, 24, 1) 0%,
    rgba(254, 161, 15, 1) 100%
  );
  opacity: 1;
  border-radius: 0.22rem;
  margin-left: 0.19rem;
}
.iconfonts {
  color: #fff !important;
  font-size: 0.28rem;
  display: block;
}
.activity_title {
  font-size: 0.24rem;
  color: #fff;
}
.activity_kan {
  width: auto;
  height: 0.44rem;
  padding: 0 0.2rem;
  background: linear-gradient(
    90deg,
    rgba(254, 159, 15, 1) 0%,
    rgba(254, 178, 15, 1) 100%
  );
  opacity: 1;
  border-radius: 0.22rem;
  margin-left: 0.19rem;
}
.addressBox .phone {
  margin-left: 1.1rem;
}
.corlor-yshop {
  color: #00c17b;
}
.store-box {
  padding: 0 0.3rem;
  border-bottom: 1px solid #f5f5f5;
}
.geoPage {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  z-index: 10000;
}
.product-con .store-info {
  margin-top: 0.2rem;
  background-color: #fff;
}
.product-con .store-info .title {
  padding: 0 0.3rem;
  font-size: 0.28rem;
  color: #282828;
  height: 0.8rem;
  line-height: 0.8rem;
  border-bottom: 0.01rem solid #f5f5f5;
}
.product-con .store-info .info {
  padding: 0 0.3rem;
  height: 1.26rem;
}
.store-info .icon-jiantou {
  color: #7a7a7a;
  font-size: 0.28rem;
}
.product-con .store-info .info .pictrue {
  width: 0.76rem;
  height: 0.76rem;
}
.product-con .store-info .info .pictrue img {
  width: 100%;
  height: 100%;
  border-radius: 0.06rem;
}
.product-con .store-info .info .text {
  width: 56%;
}
.product-con .store-info .info .text .name {
  font-size: 0.3rem;
  color: #282828;
}
.product-con .store-info .info .text .address {
  font-size: 0.24rem;
  color: #666;
  margin-top: 0.03rem;
}
.product-con .store-info .info .text .address .iconfont {
  color: #707070;
  font-size: 0.18rem;
  margin-left: 0.1rem;
}
.address_tit {
  max-width: 88% !important;
}
.addressTxt {
  width: auto;
  font-size: 0.24rem;
}
.product-con .store-info .info .iconfont {
  font-size: 0.4rem;
}
.product-con .superior {
  background-color: #fff;
  margin-top: 0.2rem;
}
.product-con .superior .title {
  height: 0.98rem;
}
.product-con .superior .title img {
  width: 0.3rem;
  height: 0.3rem;
}
.productSort .conter .list {
  flex-direction: column;
}
.product-con .superior .slider-banner .list .item {
  width: 2.15rem;
  margin: 0 0.22rem 0.3rem 0;
  font-size: 0.26rem;
}
.product-con .superior .slider-banner .list .item:nth-of-type(3n) {
  margin-right: 0;
}
.product-con .superior .slider-banner .list .item .pictrue {
  width: 100%;
  height: 2.15rem;
}
.product-con .superior .slider-banner .list .item .pictrue img {
  width: 100%;
  height: 100%;
  border-radius: 0.06rem;
}
.product-con .superior .slider-banner .list .item .name {
  color: #282828;
  margin-top: 0.12rem;
}
.product-con .superior .slider-banner .swiper-pagination-bullet {
  background-color: #999;
}
.product-con .superior .slider-banner .swiper-pagination-bullet-active {
  background-color: #e93323;
}

.mask {
  -webkit-filter: blur(2px);
  -moz-filter: blur(2px);
  -ms-filter: blur(2px);
  filter: blur(2px);
}
.footer .icon-shoucang1 {
  color: #00c17b;
}
.product-con .product-intro .conter div {
  width: 100% !important;
}
.generate-posters {
  width: 100%;
  height: 1.7rem;
  background-color: #fff;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 99;
  transform: translate3d(0, 100%, 0);
  -webkit-transform: translate3d(0, 100%, 0);
  -ms-transform: translate3d(0, 100%, 0);
  -moz-transform: translate3d(0, 100%, 0);
  -o-transform: translate3d(0, 100%, 0);
  transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  -webkit-transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  -moz-transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  -o-transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
}
.generate-posters.on {
  transform: translate3d(0, 0, 0);
  -webkit-transform: translate3d(0, 0, 0);
  -ms-transform: translate3d(0, 0, 0);
  -moz-transform: translate3d(0, 0, 0);
  -o-transform: translate3d(0, 0, 0);
}
.generate-posters .item {
  flex: 50%;
  -webkit-flex: 50%;
  -ms-flex: 50%;
  text-align: center;
}
.generate-posters .item .iconfont {
  font-size: 0.8rem;
  color: #5eae72;
}
.generate-posters .item .iconfont.icon-haibao {
  color: #5391f1;
}
.noscroll {
  height: 100%;
  overflow: hidden;
}
</style>
